function dep_matrix = depmat(N,stations);
    station1 = stations(:,1);
    station2 = stations(:,2);
    station3 = stations(:,3);
    
dep_matrix = zeros(N,N);

for i = 1:N 
        for j = 1:N
            if station1(i) == station1(j)
                dep_matrix(i,j) = 1;
            end;
            if station1(i) == station2(j)
                dep_matrix(i,j) = 1;
            end;
            if station1(i) == station3(j)
                dep_matrix(i,j) = 1;
            end;
            if station2(i) == station1(j) && station2(i) ~= -9
                dep_matrix(i,j) = 1;
            end;
            if station2(i) == station2(j) && station2(i) ~= -9
                dep_matrix(i,j) = 1;
            end;
            if station2(i) == station3(j) && station2(i) ~= -9
                dep_matrix(i,j) = 1;
            end;
            if station3(i) == station1(j) && station3(i) ~= -9
                dep_matrix(i,j) = 1;
            end;
            if station3(i) == station2(j) && station3(i) ~= -9
                dep_matrix(i,j) = 1;
            end;
            if station3(i) == station3(j) && station3(i) ~= -9
                dep_matrix(i,j) = 1;
            end;   
        end;
end;

clear i j;